package ee.mtiidla.data;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;

import ee.mtiidla.utils.TextUtils;

/**
 * Created by Marko on 12.10.2014.
 */
@XmlAccessorType(XmlAccessType.FIELD)
public class Swimstyle {

	@XmlAttribute(name = "swimstyleid")
	private long swimstyleId;

	@XmlAttribute(name = "code")
	private String code;

	@XmlAttribute(name = "distance")
	private int distance;

	@XmlAttribute(name = "name")
	private String name;

	@XmlAttribute(name = "relaycount")
	private int relayCount;

	@XmlAttribute(name = "stroke")
	private String stroke;

	public long getSwimstyleId() {
		return swimstyleId;
	}

	public void setSwimstyleId(long swimstyleId) {
		this.swimstyleId = swimstyleId;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public int getDistance() {
		return distance;
	}

	public void setDistance(int distance) {
		this.distance = distance;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getRelayCount() {
		return relayCount;
	}

	public void setRelayCount(int relayCount) {
		this.relayCount = relayCount;
	}

	public String getStroke() {

		if (TextUtils.isEmpty(stroke)) {
			return "";
		} else if (stroke.toLowerCase().equals("free")) {
			return "Freestyle";
		} else if (stroke.toLowerCase().equals("back")) {
			return "Backstroke";
		} else if (stroke.toLowerCase().equals("breast")) {
			return "Breaststroke";
		} else if (stroke.toLowerCase().equals("fly")) {
			return "Butterfly";
		} else if (stroke.toLowerCase().equals("medley")) {
			return "Medley";
		}

		return stroke;
	}

	public void setStroke(String stroke) {
		this.stroke = stroke;
	}

	public String toString() {

		String result = "";

		if (relayCount > 1) {
			result += relayCount + "x";
		}

		return result + distance + "m " + getStroke();
	}

}
